import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import './assets/styles/reset.css'
import './assets/styles/common.css'
import './plugins/element.js'
import './assets/fonts/iconfont.css'
import './assets/css/global.css'
import axios from 'axios'
import Nprogress from 'nprogress'
import 'nprogress/nprogress.css'
import Viewer from 'v-viewer'
import 'viewerjs/dist/viewer.css'
import ECharts from 'vue-echarts'
import 'echarts/lib/chart/line'

// 富文本编辑器
import VueQuillEditor from 'vue-quill-editor'
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'

import echarts from 'echarts'
Vue.prototype.$echarts = echarts

Vue.use(Viewer, {
  defaultOptions: {
    zIndex: 9999
  }
})

Vue.use(VueQuillEditor)
// axios.defaults.baseURL = 'http://111.231.142.21/api'
// axios.defaults.basesURL = 'http://localhost:5000' // 默认基础路径配
axios.defaults.baseURL = '' // api 即上面 vue.config.js 中配置的地址
axios.defaults.withCredentials = true // 跨域保存session

// Vue.filter('dateformat', function(dataStr, pattern = 'YYYY-MM-DD HH:mm:ss') {
//   return moment(dataStr).format(pattern)
// })

axios.interceptors.request.use(config => {
  // console.log(config)
  Nprogress.start()
  config.headers.Authorization = window.sessionStorage.getItem('token')
  // 在最后必须 return config
  return config
})
axios.interceptors.response.use(config => {
  // console.log(config)
  Nprogress.done()
  return config
})

Vue.prototype.$http = axios
Vue.component('chart', ECharts)
Vue.config.productionTip = false

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
